var gulp = require('gulp'),
    compass = require('gulp-compass');

function handleErrors(e){
    console.log(e);
}

function registerTasks(dir){
    return (function (){
        gulp.task(dir+'task',function(){
            makeAll(dir);
        });
        gulp.task(dir,function(){
            gulp.watch('media/'+dir+'/sass/**/*.scss', [dir+'task']);
        });
    })()
    function makeAll(name){
        return gulp.src('media/'+name+'/sass/**/*.scss')
            .pipe(compass({
                import_path:'media',
                config_file:'config/'+name+'.rb',
                css:'media/'+name+'/css'
            }))
            .on('error', handleErrors)
            .pipe(gulp.dest('media/'+name+'/css'));
    }
}
// 通用
registerTasks('com');
// 教师
registerTasks('tea');
// 学生
registerTasks('stu');
